"""Definition of the consultation content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

# -*- Message Factory Imported Here -*-
from my315ok.xtinfocontent import xtinfocontentMessageFactory as _

from my315ok.xtinfocontent.interfaces import Iconsultation
from my315ok.xtinfocontent.config import PROJECTNAME

consultationSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

     atapi.StringField(
        'category',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"category"),
            description=_(u""),
        ),
        required=True,
    ),
      

    atapi.StringField(
        'nickname',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"nickname"),
            description=_(u""),
        ),
    ),


    atapi.IntegerField(
        'qq',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"qq number"),
            description=_(u""),
        ),
        validators=('isInt'),
    ),

 atapi.ImageField(
        'photo',
        storage=atapi.AnnotationStorage(),
        widget=atapi.ImageWidget(
            label=_(u"photo"),
            description=_(u""),
        ),
        validators=('isNonEmptyFile'),
    ),

 atapi.TextField(
        'text',
        storage=atapi.AnnotationStorage(),
        widget=atapi.RichWidget(
            label=_(u"consultation content"),
            description=_(u""),
        ),
    ),


))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

consultationSchema['title'].storage = atapi.AnnotationStorage()
consultationSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(consultationSchema, moveDiscussion=False)


class consultation(base.ATCTContent):
    """consultation"""
    implements(Iconsultation)

    meta_type = "consultation"
    schema = consultationSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    photo = atapi.ATFieldProperty('photo')

    text = atapi.ATFieldProperty('text')

    nickname = atapi.ATFieldProperty('nickname')

    qq = atapi.ATFieldProperty('qq')

    category = atapi.ATFieldProperty('category')


atapi.registerType(consultation, PROJECTNAME)
